<?php use_helper('Date'); $sf_user->setCulture('ru_RU'); ?>

<?php slot('related')?>
<?php include_component('releases','last_releases',array('howmuch'=>3)) ?>
<?php include_component('news','lastnews',array('howmuch'=>3)) ?>
<?php end_slot();?>

<?php slot('tenderlaw') ?>
<?php include_component('tenderlaw', 'getlaw') ?>
<?php end_slot(); ?>

<h2 class="block_title_red"><span>Тендеры</span></h2>

<?php if($Region!=''):?><br/>
	<?php echo link_to('Обратно к списку всех регионов','tenders/index')?>
<?php endif;?>

<?php if ($pager->haveToPaginate()): ?>
	<?php include_partial('tenders/pagination',array('pager'=>$pager,'Region'=>$Region))?>
<?php endif;?>

<?php 
$tenders = $pager->getResults();
if(count($tenders)>0):?>
	<table class="tenders">
		<thead>
			<tr>
				<th>Дата</th>
				<th>Предмет закупки</th>
				<th onmouseout="$('#region_selector').hide();">
					<ul class="region_selector">
						<li onmouseover="$('#region_selector').show()">
							<span class="region_select"><a href="javascript://" >Регион <img src='/images/downarrow.png'></a></span>
							<ul id="region_selector" style="display:none;" >
								<?php foreach ($regions as $region): ?>
									<li><a href="javascript://" onclick="document.location='/tenders/region/region_id/<?php echo $region['id']?>'"><?php echo $region['name']?></a></li>
								<?php endforeach;?>
								<!-- $('#ajax_loader').show();-->
								</li>
							</ul>
						</li>
					</ul>
				</th>
				<th>Организация</th>
			</tr>
		</thead>
	<?php foreach($tenders as $tender):?>
		<tr <?php echo ($tender->isPast())?' class="past_tender"':''?>>
			<td><?php echo format_datetime($tender['tender_date'],'d')?></td>
			<td><?php echo $tender['title']?><br />
				<?php echo link_to('Далее »»','tender_view',$tender)?></td>
			<td><?php echo $tender['Region']['name']?></td>
			<td><?php echo $tender['company']?></td>
		</tr>
	<?php endforeach;?>
	</table>
	<?php if(isset($Region)):?>
		<?php echo link_to('К списку тендеров','tenders/index')?></p>
	<?php endif;?>
	<!-- div id="ajax_loader"></div-->
<?php elseif(!isset($Region)):?>
	<p style="padding:10px 0;">На данный момент нет активных тендеров</p>
<?php else:?>
	<p style="padding:10px 0;">На данный момент по текущему региону нет активных тендеров<br/>
	<?php echo link_to('К списку тендеров','tenders/index')?></p>
<?php endif;?>

<?php if ($pager->haveToPaginate()): ?>
	<?php include_partial('tenders/pagination',array('pager'=>$pager,'Region'=>$Region))?>
<?php endif;?>